<template>
  <div
    class="module-title"
    :style="{
      backgroundImage: `url(${bg === 'short' ? short : long})`,
      backgroundSize: '100% 100%',
    }"
  >
    <div class="title-label">{{ label }}</div>
    <div
      class="title-right"
      :style="{
        marginRight: bg === 'short' ? '37px' : '50px',
      }"
    >
      <div v-if="text" class="title-text">{{ text }}</div>
      <slot name="right" />
    </div>
  </div>
</template>
<script>
import short from "@/assets/title-bg.png";
import long from "@/assets/title-bg-2.png";
export default {
  name: "module-title",
  props: {
    // 标题
    label: {
      type: String,
      default: "",
    },
    // 显示内容
    text: {
      type: String,
      default: "",
    },
    // 背景图
    bg: {
      type: String,
      default: "short",
    },
  },
  data() {
    return {
      short,
      long,
    };
  },
};
</script>
<style lang="scss" scoped>
.module-title {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .title-label {
    font-weight: 800;
    font-size: 20px;
    color: #ffffff;
    line-height: 23px;
    letter-spacing: 1px;
    margin-left: 30px;
  }
  .title-right {
    display: flex;
    align-items: center;
    .title-text {
      min-width: 151px;
      height: 28px;
      background: url("~@/assets/count-bg.png") no-repeat;
      background-size: 100% 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      font-family: PingFang SC;
      font-weight: 800;
      font-size: 11px;
    }
  }
}
</style>
